#include <iostream>
#include <vector>

using namespace std;

class Solution {
public:
    int maximumSum(vector<int>& arr) {
        int last_new_sum = 0, new_sum = 0, skip_sum = 0;
        int result = INT32_MIN;
        for (auto arr_num: arr) {
            skip_sum = max(skip_sum + arr_num, last_new_sum + arr_num);
            last_new_sum = new_sum;
            new_sum = max(arr_num, new_sum + arr_num);
            result = max(max(result, skip_sum), new_sum);
        }
        return result;
    }
};

int main() {
    vector<int> input = {-1, -1, -1, -1};
    Solution solution;
    int result = solution.maximumSum(input);
    std::cout << result << std::endl;
    return 0;
}